// JS-S00198 detect 2022B
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
constexpr int N = 1e5 + 7, M = N;
int n, m, L, V;
int d[N], v[N], a[N], p[M], blkn = 0;
pair<int, int> blk[N];

inline double calcs(int v0, int a) {
    return (double)(V * V - v0 * v0) / a / 2;
}

int main() {
    ios::sync_with_stdio(false);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while (T--) {
        blkn = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        sort(p + 1, p + m + 1);
        int& pmx = p[m], &pmn = p[1];
        int ans = 0, ans2 = 1;
        for (int i = 1; i <= n; i++) {
            if (d[i] > pmx) continue;
            if (a[i] == 0) {
                if (v[i] > V && d[i] <= pmx) {
                    ans++;
                    blk[++blkn] = make_pair(*lower_bound(p + 1, p + m + 1, d[i]), pmx);
                }
                continue;
            }
            if (a[i] > 0) {
                double dis = d[i] + calcs(v[i], a[i]);
                if (dis < pmx) {
                    ans++;
                    blk[++blkn] = make_pair(*upper_bound(p + 1, p + m + 1, dis), pmx);
                }
                continue;
            }
            if (v[i] <= V) continue;
            int dis = *lower_bound(p + 1, p + m + 1, d[i]);
            double vdis = calcs(v[i], a[i]) + d[i];
            if (dis < vdis) {
                ans++;
                blk[++blkn] = make_pair(dis, p[lower_bound(p + 1, p + m + 1, vdis) - p - 1]);
            }
        }
        sort(blk + 1, blk + blkn + 1);
        int _r = blk[1].second;
        for (int i = 2; i <= blkn; i++) {
            if (blk[i].first > _r) ans2++, _r = blk[i].second;
            else _r = min(blk[i].second, _r);
        }
        cout << ans << ' ' << m - ans2 << endl;
    }
    return 0;
}
